/**
 * @Author: Nick Zhang <thesadboy@vip.qq.com>
 * @Description: 插件设置存储
 * @Date: 2024-06-17 08:21:31
 * @LastEditors: Nick Zhang <thesadboy@vip.qq.com>
 * @LastEditTime: 2024-07-03 13:28:53
 */
package com.nickzhang.jetbrains.file_description_plugin.configs

import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.components.PersistentStateComponent
import com.intellij.openapi.components.RoamingType
import com.intellij.openapi.components.State
import com.intellij.openapi.components.Storage
import com.intellij.util.xmlb.XmlSerializerUtil

/**
 * File Description
 */
@State(
    name = "com.nickzhang.jetbrains.file_description_plugin.config.DescriptionState",
    storages = [Storage("fileDescription.xml", roamingType = RoamingType.DEFAULT)]
)
class AppSettingState : PersistentStateComponent<AppSettingState> {
    var openFileCheck: Boolean = false
    var createFileAdd: Boolean = true
    var changeUpdate: Boolean = true
    var funCommentInHeaderComment: Boolean = false
    var compactComment: Boolean = false
    var customHeaderComment: String = ""
    var ignorePaths: String = ".git/*\n.idea/*\n.vscode/*\nnode_modules/*"

    override fun getState(): AppSettingState {
        return this
    }

    override fun loadState(state: AppSettingState) {
        XmlSerializerUtil.copyBean(state, this)
    }

    companion object {
        fun getInstance(): AppSettingState {
            return ApplicationManager.getApplication().getService(AppSettingState::class.java)
        }
    }
}
